<?php
/**
 * Created by PhpStorm.
 * User: 小灰灰
 * Date: 2023-03-23
 * Time: 11:37:14
 * Info:
 */

namespace app\common\model;

use think\facade\Db;

class App extends TimeInit
{

    public function addInstall($info)
    {
        $this->save([
            'name'        => $info['name'],
            'title'       => $info['title'] ?? '',
            'image'       => $info['image'] ?? '',
            'price'       => $info['price'] ?? 0,
            'module'      => $info['module'] ?? '',
            'type'        => $info['type'],
            'description' => $info['description'] ?? '',
            'author'      => $info['author'] ?? '',
            'version'     => $info['version']['version'] ?? $info['version'],
            'status'      => 1,
            'create_time' => time(),
            'update_time' => time()
        ]);
    }

    public function editInstall($info)
    {
        $this->where(['name' => $info['name'], 'type' => $info['type']])->save([
            'name'        => $info['name'],
            'title'       => $info['title'],
            'image'       => $info['image'],
            'price'       => $info['price'],
            'module'      => $info['module'] ?? '',
            'type'        => $info['type'],
            'description' => $info['description'] ?? '',
            'author'      => $info['author'] ?? '',
            'version'     => $info['version']['version'],
            'status'      => 1,
            'create_time' => time(),
            'update_time' => time()
        ]);
    }

}
